<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="../img/asset-favico.ico">
        <title>预约须知</title>
        <link rel="stylesheet" href="../css/page-health-orderNotice.css" />
        <script src="../plugins/jquery/dist/jquery.min.js"></script>
        <script src="../plugins/healthmobile.js"></script>
        <script src="../plugins/vue/vue.js"></script>
        <script src="../plugins/vue/axios-0.18.0.js"></script>

        <!--根据url生成二维码-->
        <script src="../js/qrcode.min.js"></script>
        <script>
            var id = getUrlParam("id");
        </script>
    </head>
    <body data-spy="scroll" data-target="#myNavbar" data-offset="150">
        <div id="app" class="app">
            <!-- 页面头部 -->
            <div class="top-header">
                <span class="f-left"><i class="icon-back" onclick="history.go(-1)"></i></span>
                <span class="center">传智健康</span>
                <span class="f-right"><i class="icon-more"></i></span>
            </div>
            <!-- 页面内容 -->
            <div class="contentBox">
                <div id="qrCode"></div>
            </div>
        </div>
    </body>
    <script>
        var url = "";
        var vue = new Vue({
            el:'#app',
            data:{
                orderInfo:{},
            },
            created(){
               axios.get("/order/weixinay/"+id).then((res)=>{
                  if(res.data.flag){
                      url = res.data.data;
                  }
               });
            }
        });
        function qr(url) {
            var qrCode = new QRCode('qrCode',{
                text:url,
                width:100,
                height:100,
                // colorLight: '#e21918',
                // colorDark: '#0078d7',
                correctLevel: QRCode.CorrectLevel.M
            });
        }
        //延时函数
        var a=setInterval(function() {
            console.log("url:"+url);
            if (url != "") {
                qr(url);
                window.clearInterval(a);
            }
            //延时判断是否成功
        },500);
        var m=setInterval(function(){
            axios.get("/order/isSuccess/"+id).then((res)=>{
                if(res.data.flag){
                    //  预约成功  跳转 预约成功页面  orderSuccess.html
                    window.location.href="orderSuccess.html?id="+id
                }else{
                    console.log("没有完成");
                }
            });
        },5000);
        setTimeout(function () {
            window.location.href='index.html';
        },200000);
    </script>
</html>
